package com.my.kq.controller;

public class Tshu {
    public static int tshu(String strat,String end){
        String[] split = strat.split("-");
        String[] end1 = end.split("-");
        int days=0;
        if(Integer.parseInt(split[0])<Integer.parseInt(end1[0])){
            for (int i = Integer.parseInt(split[0]); i <Integer.parseInt(end1[0]) ; i++) {
                  if(i%4==0&&i%100!=0||i%400==0){
                      days+=366;
                  }else {
                      days+=356;
                  }
            }
        }
        int Starday=days(split[0],split[1],split[2]);
        int ends=days(end1[0],end1[1],end1[2]);
       days=days-Starday+ends;
        return days;
    }

    public static  int days(String year,String month,String day){
        int days=0;
        int nowyear = Integer.parseInt(year);
        int[]mothday={0,31,28,31,30,31,30,31,31,30,31,30,31};
        int[]mothday1={0,31,29,31,30,31,30,31,31,30,31,30,31};

        boolean flag=true;
        if(nowyear%4==0&&nowyear%100!=0||nowyear%400==0){

        }else {
            flag=false;
        }
        for (int i = 0; i <Integer.parseInt(month) ; i++) {
            if(flag){
                days+=mothday1[i];
            }else {
                days+=mothday[i];
            }
        }
       days+=Integer.parseInt(day);

        return days;
    }
}
